<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-row :gutter="20">
        <el-col  :xs="24" :sm="12" :lg="6">
          <el-form-item label="">
            <el-date-picker
              v-model="queryParams.queryTime"
              type="daterange"
              start-placeholder="Start Date"
              end-placeholder="End Date"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
            />
          </el-form-item>
        </el-col>
        
        <el-col  :xs="24" :sm="12" :lg="6">
          <el-form-item label="资产名称" prop="wgname">
            <el-input
              v-model="queryParams.wgname"
              placeholder="请输入资产名称"
              clearable
              @keyup.enter="handleQuery"
            />
          </el-form-item>
        </el-col>

        <el-col :xs="24" :sm="12" :lg="6">
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-table v-loading="loading" :data="analysisList" @selection-change="handleSelectionChange">
      <el-table-column label="资产名称" align="center" prop="wgname" />
      <el-table-column label="成本" sortable align="center" prop="carPrice" />
      <el-table-column label="收益" sortable align="center" prop="income" />
      <el-table-column label="支出" sortable align="center" prop="expenditure" />
      <el-table-column label="收益率" sortable align="center" prop="rateOfReturn" />
      <el-table-column label="日均收益率" sortable align="center" prop="dailyRateOfReturn" />
      <el-table-column label="订单数量（频次）" sortable align="center" prop="orderQuantity" />
      <el-table-column label="使用天数" sortable align="center" prop="daysOfUse" />
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="Analysis">
import { listAnalysis } from "@/api/operate/analysis";

const analysisList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10000,
    queryTime: '',
    wgname: null,
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询会员管理列表 */
function getList() {
  loading.value = true;
  listAnalysis(queryParams.value).then(response => {
    analysisList.value = response.data;
    loading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

getList();
</script>
